<template>
	<!-- 关注-粉丝 -->
	<view>
		<!-- 头部 -->
		<hx-navbar ref="hxnb" :config="config" />
		<!-- 内容 -->
		<view class="content" style="margin-top:18rpx ;">
			<view class="flex" style="padding: 20rpx;margin-bottom: 5rpx;background-color: #fff;"
				v-for="(item,index) in listdate" :key="index" @click="Homepage(item.focusedId,item.userType)"
				v-if="item.operation == 1">
				<view>
					<view class="flex">
						<image style="width: 94rpx;height:94rpx;" :src="item.userImage" mode=""></image>
						<view style="padding: 0 10rpx;line-height: 48rpx;">
							<view style="display: flex;font-size: 32rpx;">
								{{item.userName}}
							</view>
							<view
								style="font-size: 28rpx;color: #9A9898;white-space: nowrap;overflow: hidden;text-overflow: ellipsis;width: 348rpx;">
								{{item.addtime}}
							</view>
						</view>
					</view>
				</view>
				<!-- <view class="attention" v-if="concern==0" style="margin-left:50rpx;z-index: 9999;" @click="getConcern">
					关注</view> -->
				<view @click="sheet" v-if="concern==1" class="attention"
					style="z-index: 9999;margin-left:50rpx;color: #1E1E1EFF;background-color: #ECECECFF;">
					已关注
				</view>
			</view>
		</view>
		<!-- 弹窗 -->
		<uni-popup id="popup" ref="sheet" type="bottom" :animation="true">
			<view style="text-align: center;padding: 30rpx;background-color: #ECECECFF;" @click="cancelConcern">
				取消关注
			</view>
		</uni-popup>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				config: {
					title: '粉丝',
					color: '#111111',
					backgroundColor: [1, '#FFFFFF'],
					border: true,
					// #ifdef H5
					backPage: '',
					// #endif
				},
				listdate: [],
				publishType: '',
				concern: '',
				type: ''
			}
		},
		onLoad(e) {
			this.type = e.type
			if (this.type == 1) {
				this.config.title = '关注'
			} else {
				this.config.title = '粉丝'
			}
			console.log('被关注', e.type)
		},
		created() {
			this.getConcern(1, 10)
		},
		methods: {
			Homepage(usId, userType) {
				this.$tools.goPageNoAuth('../decoration/homepage?Id=' + usId + '&usType=' + userType)
			},
			sheet() {
				this.$refs.sheet.open()
			},
			// 取消关注
			cancelConcern() {
				let data = {
					focusedId: this.id,
					userType: this.userType,
					operation: 0
				}
				this.$api.unConcern(data).then((res) => {
					this.$refs.sheet.close()
					this.getNotes()
				})
			},
			getConcern(num, size) {
				let data = {
					pageNo: num,
					pageSize: size,
				}
				if (this.type == 1) {
					this.$api.concernList(data).then((res) => {
						res.data.result.list.forEach((item) => {
							item.addtime = this.$tools.fileTime(item.addtime)
						})
						this.listdate = res.data.result.list
						if (num == 1) {
							this.listdate = res.data.result.list
						} else {
							this.listdate = this.projectList.concat(res.data.result.list)
						}
						this.mescroll.endBySize(res.data.result.list.length, res.data.result
							.total);
						console.log('宋人头的亚轩', res)
					})
				} else if (this.type == 2) {
					this.$api.fansList(data).then((res) => {
						res.data.result.list.forEach((item) => {
							item.addtime = this.$tools.fileTime(item.addtime)
						})
						this.listdate = res.data.result.list
						if (num == 1) {
							this.listdate = res.data.result.list
						} else {
							this.listdate = this.projectList.concat(res.data.result.list)
						}
						this.mescroll.endBySize(res.data.result.list.length, res.data.result
							.total);
						console.log('宋人头的亚轩', this.listdate)
					})
				}

			},
			//返回上一页
			goBack() {
				uni.navigateBack(1)
			},
		}
	}
</script>

<style scoped>
	.image {
		width: 214rpx;
		height: 158rpx;
	}

	.flex {
		display: flex;
		justify-content: space-between;
	}
</style>
